<?php
$width=Yii::app()->params['dialog']['findTruckForConstantExpense']['width'];
$height=Yii::app()->params['dialog']['findTruckForConstantExpense']['height'];
$cs=Yii::app()->clientScript;
$cs->registerScriptFile('./js/modal.js');
$cs->registerScript('tuck_constant_expense_dialog',<<<END
function Block(){\$.modal('?r=dialog/findTruckForConstantExpense',{width:$width,height:$height,title:'请选择车辆'});return false;}
$("#findTruck").click(Block);
var truck_constant;
function check_constant(){
	if(!$("#ejsvformid1").valid()) return false;
	$.ajax({'type':'POST','url':'?r=constant_expense/checkConstant','async':false,'cache':false,'data':'truck_id='+$("#Constant_expense_fk_truck_id").val()+'&effect_date='+$('#effect_date').val()+'&lapse_date='+$('#lapse_date').val()+'&constant_id=$model->id','success':function(data){truck_constant=data;}});
	if(truck_constant==1) {alert("此车辆相对应时间段的月固定费用已存在!");return false;}
	return true;
}
$('form').submit(check_constant);
END
)
?>
<div class="yiiForm">
<?php
	echo EHtml::form();	
	EHtml::setOptions(array('errorElement'=> 'span'));
	EHtml::setScenario($update ? 'update' : 'create');				  		
?>
<div>注：<span class="required">*</span>为必填项</div>
<div id="leftaa" style=" border-bottom:0px solid #90b3bc;">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'plate_no'); ?>
<?php echo EHtml::activeTextField($model,'plate_no',array('size'=>10,'class'=>'readonly','readOnly'=>'true'));?>
<?php echo CHtml::activeHiddenField($model,'fk_truck_id');?> &nbsp;&nbsp;<a id="findTruck" href="#">查找车辆</a>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'depreciation'); ?>
<?php echo EHtml::activeTextField($model,'depreciation'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'wage_expenditure'); ?>
<?php echo EHtml::activeTextField($model,'wage_expenditure'); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'handling_cost'); ?>
<?php echo EHtml::activeTextField($model,'handling_cost'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'effect_date'); ?>
<?php echo EHtml::activeTextField($model,'effect_date',array('size'=>8,'maxlength'=>10,'id'=>"effect_date",'value'=>substr($model->effect_date,0,7))); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'effect_date','ifFormat'=>'%Y-%m',));?>
(从此月初生效)
</div>
</div>
  <div id="rightaa" style=" border-bottom:0px solid #90b3bc;">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'gps_cost'); ?>
<?php echo EHtml::activeTextField($model,'gps_cost'); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'another_cost'); ?>
<?php echo EHtml::activeTextField($model,'another_cost'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'the_other_cost'); ?>
<?php echo EHtml::activeTextField($model,'the_other_cost'); ?>
</div>
<div class="simple1">

</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'lapse_date'); ?>
<?php echo EHtml::activeTextField($model,'lapse_date',array('size'=>8,'maxlength'=>10,'id'=>"lapse_date",'value'=>substr($model->lapse_date,0,7))); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'lapse_date','ifFormat'=>'%Y-%m',));?>
(至此月末失效)
</div>
</div>
<div class="action">
<?php echo EHtml::submitButton($update ? '更新信息' : '添加信息'); ?>
</div>

<?php echo EHtml::endForm(); ?>

</div><!-- yiiForm -->
<?php 
if($model->hasErrors()) echo "<script>alert('您填写的信息有误！请根据页面红色图标提示修改。');</script>";
?>